<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['diy']=$this->plugin_setting('diy');
$basic=$this->plugin_setting('basic');
$return['banner']=$basic['image'];
$return['basic']=$basic;
if($_RQ['op']=='main'){
	//按捐款笔数排序项目
	$list=pdo_getall('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'is_shenhe'=>'1','status'=>'0'),'','jtimes desc');
	$sum=0;
	$look= pdo_getsum('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'is_shenhe'=>'1','status'=>'0'),'look');
	$jtimes= pdo_getsum('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'is_shenhe'=>'1','status'=>'0'),'jtimes');
	if($list){
		$sum=count($list);
		foreach($list as &$item){
			$classify=pdo_get('jy_zhongchou_classify',array('id'=>$item['cid'],'uniacid'=>$_SESSION['uniacid']));
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			$item['classify']=$classify;
			$item['shouchishenfenz']=json_decode($item['shouchishenfenz'],true);
			$item['hospitalz']=json_decode($item['hospitalz'],true);
			$item['buchong']=json_decode($item['buchong'],true);
		}
	}
	$return['params']=array();
	$return['list']=$list;
	$return['sum']=$sum;
	$return['look']=$look;
	$return['jtimes']=$jtimes;
	set_html('title','项目列表');
	exi($return);
}
if($_RQ['op']=='getlist'){
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>0,'is_shenhe'=>1);
	if($_RQ['keyword']){
		if(is_numeric($_RQ['keyword'])){
			$params['id']=intval($_RQ['keyword']);
			$return['params']['id']=intval($_RQ['keyword']);
		}else{
			$params['title like']='%'.$_RQ['keyword'].'%';
			$return['params']['title']=$_RQ['title'];
		}
	}
		
	//按捐款笔数排序项目
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$list=pdo_getslice('jy_zhongchou_project',$params,array($pindex,$psize),$total,$fields,'','jtimes desc, id desc');
	if($list){
		foreach($list as &$item){
			$classify=pdo_get('jy_zhongchou_classify',array('id'=>$item['cid'],'uniacid'=>$_SESSION['uniacid']));
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			$item['classify']=$classify;
			$item['shouchishenfenz']=json_decode($item['shouchishenfenz'],true);
			$item['hospitalz']=json_decode($item['hospitalz'],true);
			$item['buchong']=json_decode($item['buchong'],true);
		}
	}
	$return['list']=$list;
	exi($return);
}
	
